
from django.contrib import admin
from TestModel.models import Test
from TestModel.models import Contact
from TestModel.models import Tag

class TagInline(admin.TabularInline):
    model = Tag

# 定义需要联合的数据模型
class ContactAdmin(admin.ModelAdmin):
    list_display = ('name','age', 'email') # list
    search_fields = ('name',)
    inlines = [TagInline]  # Inline
    # 通过以下关键字，对字段进行分块显示
    fieldsets = (
        ['Main',{
            'fields':('name','email'),
        }],
        ['Advance',{
            'classes': ('collapse',), # CSS
            'fields': ('age',),
        }]
    )
# Register your models here.
# 注册test实体，可在django自带的后台管理模板中进行管理
# admin.site.register([Test, Contact, Tag])

admin.site.register(Contact, ContactAdmin)
admin.site.register([Test])